import { computed } from 'vue';
import { storeToRefs } from 'pinia';
import { useAppStore } from './modules/app';
import { usePlayerStore } from './modules/player';

export const useMyStores = function () {

  const appStore = useAppStore();
  const playerStore = usePlayerStore();

  const { tabBar, isLogin, userinfo } = storeToRefs(appStore);
  const {
    miniPlayer,
    fullPlayer,
    audioReady,
    audioPlayTime,
    audioTotalTime,
    audioPlayState,
    currentPlayMode,
    currentPlayIndex,
    currentPlayList,
    currentPlayHistory,
    currentSearchHistory,
    currentFavoriteList,
    currentMyPlayList,
    lyric,
    lyricIndex,
    lyricIndexTxt
  } = storeToRefs(playerStore);
  
  const currentPlaySong = computed(() => currentPlayList.value[currentPlayIndex.value] || {});

  return {
    // store
    appStore,
    playerStore,

    // 属性
    tabBar,
    isLogin,
    userinfo,

    miniPlayer,
    fullPlayer,

    audioReady,
    audioPlayState,
    audioPlayTime,
    audioTotalTime,

    currentPlayMode,
    currentPlayIndex,
    currentPlayList,
    currentPlayHistory,
    currentSearchHistory,
    currentFavoriteList,
    currentMyPlayList,
    
    currentPlaySong,

    lyric,
    lyricIndex,
    lyricIndexTxt
  };
};
